Passed
Push — main ( 3f259d...71e4ad )
by Patrick
02:34
created

Boost   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 42
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 14
1
// Generated by dts-bundle-generator v7.1.0
2
3
import { SimpleGit } from 'simple-git';
4
import { Logger } from 'winston';
5
6
export type LogTarget = "console" | "file";
7
declare class HasLogger {
8
	logger: Logger;
9
	createLogger(targets: LogTarget[], defaultMeta: Record<string, any>): void;
10
	log(message: string, meta?: any[]): void;
11
}
12
export interface AppSettings {
13
	github_token: string;
14
	repository_storage_path: string;
15
	boosts_path: string;
16
	use_forks: boolean;
17
	use_pull_requests: boolean;
18
	log_target: LogTarget | LogTarget[];
19
	dry_run?: boolean;
20
	auto_merge_pull_requests?: boolean;
21
}
22
export type BoostHistory = BoostHistoryItem[];
23
declare enum BoostHistoryItemState {
24
	SUCCEEDED = "succeeded",
25
	FAILED = "failed",
26
	RUNNING = "running",
27
	SKIPPED = "skipped",
28
	UNKNOWN = "unknown"
29
}
30
export interface BoostHistoryItem {
31
	run_id: string;
32
	boost: string;
33
	version: string;
34
	repository: string;
35
	pull_request: number | null;
36
	state: BoostHistoryItemState;
37
	started_at: string;
38
	finished_at: string | null;
39
	[key: string]: any;
40
}
41
export interface RepositoryInfo {
42
	owner: string;
43
	name: string;
44
}
45
declare class Repository {
46
	name: string;
47
	owner: string;
48
	path: string;
49
	gitInstance: SimpleGit;
50
	get info(): RepositoryInfo;
51
	get git(): SimpleGit;
52
	initGitListeners(runId: string): void;
53
	constructor(fullRepositoryName: string, repositoryStoragePath: string);
54
	clone(): Promise<boolean>;
55
	prepare(): Promise<void>;
56
	localBranches(): Promise<import("simple-git").BranchSummary>;
57
	currentBranch(): Promise<string>;
58
	onBranch(branchName: string): Promise<boolean>;
59
	checkout(branchName: string): Promise<void>;
60
	defaultBranch(): Promise<string>;
61
	createFork(): Promise<void>;
62
	pushToFork(branchName: string): Promise<void>;
63
	fullRepositoryName(): string;
64
}
65
export type OnFileCopiedCallback = (src: string, dest: string) => void;
66
declare class Tools {
67
	sleep(ms: number): Promise<unknown>;
68
	fileexists(path: string): boolean;
69
	readfile(path: string): string;
70
	writefile(path: string, content: string): void;
71
	copyfile(src: string, dest: string): string;
72
	hashfile(path: string): string;
73
	hashstring(str: string): string;
74
	filesAreEqual(file1: string, file2: string): boolean;
75
	readYaml(path: string): any;
76
	writeYaml(path: string, data: any): void;
77
	readJson(path: string): any;
78
	writeJson(path: string, data: any): void;
79
	exec(command: string, silent?: boolean): string;
80
	recursiveDirectoryCopy(src: string, dest: string, onCopiedCallback?: OnFileCopiedCallback | null): string[];
81
	protected handleDirectoriesForDirectoryCopy({ stats, srcFn, destFn, handler }: {
82
		stats: any;
83
		srcFn: any;
84
		destFn: any;
85
		handler: any;
86
	}): void;
87
	protected handleFilesForDirectoryCopy({ stats, srcFn, destFn, files, onCopiedCallback }: {
88
		stats: any;
89
		srcFn: any;
90
		destFn: any;
91
		files: any;
92
		onCopiedCallback: any;
93
	}): void;
94
}
95
export interface BoostConfiguration {
96
	id: string;
97
	version: string;
98
	repository_limits: {
99
		max_runs_per_version: number;
100
		minutes_between_runs: number;
101
	};
102
	pull_request: {
103
		title: string;
104
		body: string;
105
		branch: string;
106
	};
107
	scripts: {
108
		parallel: boolean;
109
		files: string[];
110
	};
111
}
112
export interface BoostScriptHandlerParameters {
113
	args: any[];
114
	boost: Boost;
115
	currentRun: BoostHistoryItem;
116
	git: SimpleGit;
117
	libs: {
118
		fs: typeof import("fs");
119
		path: typeof import("path");
120
		semver: typeof import("semver");
121
	};
122
	repository: Repository;
123
	tools: Tools;
124
}
125
declare class Boost {
126
	protected codeBoost: CodeBoost;
127
	protected repository: Repository | null;
128
	config: BoostConfiguration;
129
	path: string;
130
	id: string;
131
	version: string;
132
	repositoryLimits: {
133
		maxRunsPerVersion: number;
134
		minutesBetweenRuns: number;
135
	};
136
	pullRequest: {
137
		title: string;
138
		body: string;
139
		branch: string;
140
	};
141
	scripts: any[];
142
	actions: any[];
143
	state: Record<string, any>;
144
	changedFiles: string[];
145
	runId: string;
146
	constructor(codeBoost: CodeBoost, boostPath: string);
147
	init(boostPath: string): void;
148
	get appSettings(): AppSettings;
149
	get history(): BoostHistory;
150
	log(message: any): void;
151
	loadConfiguration(boostPath: string): BoostConfiguration;
152
	loadPullRequest(pullRequest: Record<string, any>): {
153
		title: any;
154
		body: any;
155
		branch: string;
156
	};
157
	loadScripts(scripts: string[]): any[];
158
	run(repository: Repository, args?: any[]): Promise<false | undefined>;
159
	handlePullRequestCreation({ repository, historyItem }: {
160
		repository: any;
161
		historyItem: any;
162
	}): Promise<void>;
163
	createScriptHandlerParameters(args: any[], historyItem: BoostHistoryItem): Promise<BoostScriptHandlerParameters>;
164
	runInitializationScript(params: BoostScriptHandlerParameters): Promise<void>;
165
	checkoutPullRequestBranch(): Promise<void>;
166
	updatePullRequestBranchName(): Promise<boolean>;
167
	runScripts(params: BoostScriptHandlerParameters): Promise<void>;
168
	canRunOnRepository(repo: Repository | string): boolean;
169
	protected isRunTimeRestricted(runs: BoostHistoryItem[]): boolean;
170
}
171
declare class HistoryManager {
172
	filename: string;
173
	data: BoostHistory;
174
	constructor(filename: string);
175
	for(boostName: string): BoostHistory;
176
	createEntry(item: BoostHistoryItem): BoostHistoryItem;
177
	save(): void;
178
	load(): void;
179
}
180
declare const CodeBoost_base: import("ts-mixer/dist/types/types").Class<any[], HasLogger, typeof HasLogger, false>;
181
export declare class CodeBoost extends CodeBoost_base {
182
	protected repository: Repository;
183
	appSettings: AppSettings;
184
	historyManager: HistoryManager;
185
	repositoryPrepared: boolean;
186
	constructor(appSettings: AppSettings, historyManager: HistoryManager);
187
	init(repository: Repository, appSettings: AppSettings): Promise<void>;
188
	prepareRepository(): Promise<void>;
189
	runBoost(boost: string | Boost, args: string[]): Promise<Boost>;
190
	getBoost(boostName: string): Boost;
191
}
192
193
export {};
194